/*    */ package com.zimbra.cs.mailclient.imap;
/*    */ 
/*    */ import java.util.ArrayList;
/*    */ import java.util.Date;
/*    */ import java.util.List;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AppendMessage
/*    */ {
/*    */   private Flags flags;
/*    */   private Date date;
/* 26 */   private List<Object> parts = new ArrayList();
/*    */   
/*    */   public AppendMessage() {}
/*    */   
/*    */   public AppendMessage(Flags flags, Date date, Object... parts) {
/* 31 */     flags(flags).date(date);
/* 32 */     for (Object part : parts) {
/* 33 */       part(part);
/*    */     }
/*    */   }
/*    */   
/*    */   public AppendMessage flags(Flags flags) {
/* 38 */     this.flags = flags;
/* 39 */     return this;
/*    */   }
/*    */   
/*    */   public AppendMessage date(Date date) {
/* 43 */     this.date = date;
/* 44 */     return this;
/*    */   }
/*    */   
/*    */   public AppendMessage part(Object obj) {
/* 48 */     if (((obj instanceof String)) || ((obj instanceof Literal))) {
/* 49 */       this.parts.add(obj);
/*    */     } else {
/* 51 */       throw new IllegalArgumentException("APPEND part must be url or literal");
/*    */     }
/* 53 */     return this;
/*    */   }
/*    */   
/*    */   boolean isCatenate() {
/* 57 */     return (this.parts.size() > 1) || ((!this.parts.isEmpty()) && ((this.parts.get(0) instanceof String)));
/*    */   }
/*    */   
/* 60 */   public Flags flags() { return this.flags; }
/* 61 */   public Date date() { return this.date; }
/* 62 */   public List<Object> parts() { return this.parts; }
/*    */   
/*    */   public List<Object> getData() {
/* 65 */     List<Object> data = new ArrayList();
/* 66 */     if (this.flags != null) data.add(this.flags);
/* 67 */     if (this.date != null) data.add(this.date);
/* 68 */     if (isCatenate()) {
/* 69 */       data.add(CAtom.CATENATE);
/* 70 */       List<Object> list = new ArrayList(this.parts.size());
/* 71 */       for (Object part : this.parts) {
/* 72 */         if ((part instanceof String)) {
/* 73 */           list.add(CAtom.URL);
/* 74 */           list.add(new Quoted((String)part));
/*    */         } else {
/* 76 */           list.add(CAtom.TEXT);
/* 77 */           list.add(part);
/*    */         }
/*    */       }
/* 80 */       data.add(list);
/*    */     } else {
/* 82 */       data.addAll(this.parts);
/*    */     }
/* 84 */     return data;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailclient/imap/AppendMessage.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */